﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WindowsFormsApplication1.DTO;
using System.Data.SqlClient;

namespace WindowsFormsApplication1.DAO
{
    class LanThiDAO
    {
        internal static List<LanThiDTO> GetList()
        {
            SqlConnection ketNoi = AbstractDAO.Connection();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = ketNoi;
            cmd.CommandText = @"SELECT * FROM LANTHI";

            // Thực thi câu lệnh 
            List<LanThiDTO> ds = new List<LanThiDTO>();
            SqlDataReader boDoc = cmd.ExecuteReader();
            while (boDoc.Read())
            {
                LanThiDTO lt = new LanThiDTO();
                lt.id = boDoc.GetInt32(0);
                lt.tenLanThi = boDoc.GetString(1);
                ds.Add(lt);
            }
            boDoc.Close();

            return ds;
        }
    }
}
